/**
 * problem_037.cpp
 * Copyright (C) 2011 - xrose
 */

#include <iostream>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>
using namespace std;

int isPrime(int numb)
{
    int sqrtnumb = floor(sqrt(numb));
    int i;
    if(numb < 2)
    {
        return 0;
    } else
        if(numb == 2) return 1;
    else
        if(numb%2 == 0) return 0;
    for(i = 3; i<=sqrtnumb; i=i+2)
    {
        if(numb%i == 0)
        {
            return 0;
        }
    }
    return 1;
}
int isTruncatePrime(const int abc)
{
//    cout<<abc<<endl;
//    getchar();
    int ab = abc;
    int nod = 0;
    if(!isPrime(abc)) return 0;
    while(ab>0)
    {
        if(!isPrime(ab)) return 0;
        ab = ab/10;
        nod++;      //number of digits
    }
    ab = abc;
    for(int i =nod; i>0; i--)
    {
        ab=ab%(int(pow(10, i)));
        if(!isPrime(ab)) return 0;
    }
    return 1;
}
int main (int argc, char const* argv[])
{
    int abc = 11;
    int cnt = 0, sum = 0;;

    while(1)
    {
        if(isTruncatePrime(abc))
        {
            cnt++;
            cout<<abc<<endl;
            sum+=abc;
            cout<<"--"<<sum<<endl;
            getchar();
        }
        abc+=2;
    }
	return 0;
}
